﻿/**
 * Created by Administrator on 2017/3/2 0002.
 */
var Page4={
    create:function () {
    var page={};
        page.ui=new PIXI.DisplayObjectContainer();
        var bg=Easy.CreateSprite('assets/images/page_bg.png',0,0,0,0,1);
        page.ui.addChild(bg);

        var i0=Easy.CreateSprite('assets/images/p4_i0.png',364,415,0.5,0.5,1);
        page.ui.addChild(i0);

        var i0_mask=new PIXI.Graphics();
        i0_mask.beginFill(0x0,1);
        i0_mask.drawRect(0,0,716,597);
        i0_mask.endFill();
        i0_mask.x=-745;
        i0_mask.y=97;
        page.ui.addChild(i0_mask);
        i0.mask=i0_mask;
        var i1=Easy.CreateSprite('assets/images/p4_i1.png',306,277,0.5,0.5,0);
        page.ui.addChild(i1);

        var line=Easy.CreateSprite('assets/images/page_leftLine.png',0,96,0,0,0);
        line.height=1136;
        line.blendMode=PIXI.BLEND_MODES.MULTIPLY;
        page.ui.addChild(line);
        var line1=Easy.CreateSprite('assets/images/page_leftLine1.png',11,690,0.5,0.5,0);
        page.ui.addChild(line1);

        // i1.scale.x=i1.scale.y=0.9;
        // TweenMax.to(i1.scale,1,{repeat:-1,yoyo:true,repeatDelay:0,x:1.1,y:1.1,ease:Cubic.easeInOut})

        var t0=Easy.CreateSprite('assets/images/p4_t0.png',222,768,0.5,0.5,0);
        page.ui.addChild(t0);
        var t1=Easy.CreateSprite('assets/images/p4_t1.png',303,847,0.5,0.5,0);
        page.ui.addChild(t1);
        var t2=Easy.CreateSprite('assets/images/p4_t2.png',309,985,0.5,0.5,0);
        page.ui.addChild(t2);

        var tip=Easy.CreateSprite('assets/images/tip.png',370,1105,0.5,0.5,1);
        TweenMax.to(tip,1,{repeat:-1,yoyo:true,y:1105+30,alpha:0.7,ease:Cubic.easeInOut});
        page.ui.addChild(tip);

        var bt_locate=Easy.CreateSprite('assets/images/bt_locate.png',pixiStage.x+740,1020,1,0.5,1);
        bt_locate.interactive=true;
        page.ui.addChild(bt_locate);
        bt_locate.on('pointerdown',function()
        {
            showMap();
        });

        page.In=function () {
            TweenMax.killTweensOf(i1);
            TweenMax.killTweensOf(i0);

            i1.x=306+45;i1.y=277+45;
            i0.x=364+45;i0.y=415+45;

            i0_mask.x=-745;
            TweenMax.to(i0_mask,2,{delay:0.2*0,x:23,ease:Cubic.easeInOut});

            t0.y=768+100;
            t0.alpha=0;
            TweenMax.to(t0,1,{delay:0.3*1,y:768,alpha:1,ease:Cubic.easeInOut});
            t1.y=847+100;
            t1.alpha=0;
            TweenMax.to(t1,1,{delay:0.3*2,y:847,alpha:1,ease:Cubic.easeInOut});
            t2.y=985+100;
            t2.alpha=0;
            TweenMax.to(t2,1,{delay:0.3*3,y:985,alpha:1,ease:Cubic.easeInOut});

            i1.alpha=0;
            TweenMax.to(i1,0.7,{delay:0.3*4,alpha:1,ease:Cubic.easeOut});
            i1.scale.x=i1.scale.y=5;
            TweenMax.to(i1.scale,0.7,{delay:0.3*4,x:1,y:1,ease:Cubic.easeOut,onComplete:function () {
                TweenMax.to(i1.scale,1,{x:1.1,y:1.1,yoyo:true,repeat:-1,ease:Cubic.easeInOut});
                // TweenMax.to(i1,5,{repeat:-1,yoyo:true,repeatDelay:1,x:306+90,y:277+90,ease:Linear.easeNone})
                // TweenMax.to(i0,5,{repeat:-1,yoyo:true,repeatDelay:1,x:364+90,y:415+90,ease:Linear.easeNone});
            }});

            line.x=-pixiStage.x;
            line.y=1136;
            line.alpha=0;
            TweenMax.to(line,2,{delay:0.3*3,y:96,alpha:1,ease:Cubic.easeInOut});

            line1.x=-pixiStage.x+11-30;
            line1.alpha=0;
            TweenMax.to(line1,1,{delay:0.3*3+0.1,x:-pixiStage.x+11,alpha:1,ease:Cubic.easeInOut});

        }
        page.Out=function()
        {
            // TweenMax.killChildTweensOf(page.ui,true);
            TweenMax.killTweensOf(i0_mask);
            TweenMax.killTweensOf(i1);
            TweenMax.killTweensOf(i0);

            TweenMax.killTweensOf(t0);
            TweenMax.killTweensOf(t1);
            TweenMax.killTweensOf(t2);
            TweenMax.killTweensOf(line);
            TweenMax.killTweensOf(line1);

            TweenMax.to(page.ui,0.3,{alpha:1,onComplete:function () {
                page.ui.alpha=1;
                i0_mask.x=-745;
                i1.alpha=0;
                t0.alpha=0;
                t1.alpha=0;
                t2.alpha=0;
                line.x=-30;
                line1.x=-30;
            }})
        }

    return page;
    }
}